<?php
function render_sidebar() {
    // 获取当前页面信息用于激活状态判断
    $current_page = basename($_SERVER['PHP_SELF']);
    $manage = isset($_GET['manage']) ? intval($_GET['manage']) : 1;
?>
<link rel="stylesheet" href="./resource/css/materialdesignicons.min.css">  <!-- 路径需根据实际存放位置调整 -->  
    <!-- 侧边栏样式 -->
    <style>
        .sidebar {
            width: 240px;
            background: #212a36;
            color: #fff;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            padding: 32px 0 0 0;
            box-shadow: 2px 0 12px rgba(41, 128, 255, 0.07);
            min-height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            z-index: 200;
        }
        
        .sidebar .sidebar-title {
            font-size: 1.6em;
            font-weight: bold;
            text-align: center;
            margin-bottom: 36px;
            letter-spacing: 2px;
            color: #2980ff;
        }
        
        .sidebar-title .mdi {
            margin-right: 10px;
            color: #3498db;
        }
        
        .manage-btn {
            background: #223046;
            color: #fff;
            border: none;
            outline: none;
            padding: 16px 24px;
            margin: 8px 16px;
            border-radius: 8px;
            font-size: 1.1em;
            cursor: pointer;
            display: flex;
            align-items: center;
            transition: background 0.18s, color 0.18s, box-shadow 0.18s;
            box-shadow: 0 2px 8px rgba(41, 128, 255, 0.06);
        }
        
        .manage-btn .mdi {
            font-size: 1.3em;
            margin-right: 8px;
        }
        
        .manage-btn:hover,
        .manage-btn.active {
            background: #2980ff;
            color: #fff;
            box-shadow: 0 4px 18px rgba(41, 128, 255, 0.15);
        }
        
        .manage-btn.back-to-display {
    /* 主色调采用高饱和度蓝色，形成视觉焦点 */
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    /* 增加按钮尺寸和内边距，提升存在感 */
    padding: 18px 24px;
    margin: 12px 16px 24px;
    /* 强化阴影效果，创造分层感 */
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    /* 圆角更圆润，符合现代设计趋势 */
    border-radius: 10px;
    /* 文字加粗，提升辨识度 */
    font-weight: 600;
}

/* 悬停状态强化效果 */
.manage-btn.back-to-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
    background: linear-gradient(135deg, #4f94fc, #2563eb);
}

/* 点击状态反馈 */
.manage-btn.back-to-display:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* 发光动画 */
@keyframes shine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* 响应式调整 */
@media (max-width: 900px) {
    .manage-btn.back-to-display {
        padding: 14px 6px;
        margin: 10px 6px 18px;
    }
}
        .manage-btn .mdi {
        font-size: 1.3em;
        margin-right: 8px;
    }
    @media (max-width: 900px) {
        .sidebar {
                width: 56px;
                padding: 18px 0 0 0;
            }

            .sidebar .sidebar-title {
                font-size: 1em;
                margin-bottom: 18px;
                text-align: center;
            }

            .sidebar .sidebar-title span {
                display: block;
                margin: 0 auto;
            }

            .manage-btn {
                padding: 12px 6px;
                font-size: 1em;
                margin: 6px 6px;
                justify-content: center;
            }

            .manage-btn span:not(.mdi) {
                display: none;
            }

            .manage-btn .mdi {
                margin-right: 0;
            }

            .main-content {
                margin-left: 56px;
                padding: 24px 12px;
            }
    }
    @media (max-width: 600px) {
        .sidebar { font-size: 0.92em;}
    }
    </style>

    <!-- 侧边栏HTML结构 -->
    <div class="sidebar">
        <div class="sidebar-title"><span class="mdi mdi-trophy"></span>管理后台</div>
        <button class="manage-btn back-to-display" onclick="location.href='index.php'">
            <span class="mdi mdi-home"></span>返回展示页
        </button>
        <button class="manage-btn<?= $current_page == 'announcement_manage.php' ? ' active' : '' ?>"
            onclick="location.href='announcement_manage.php'">
            <span class="mdi mdi-bullhorn"></span>公告
        </button>
        <button class="manage-btn<?= ($current_page == 'praise_manage.php' && $manage == 1) ? ' active' : '' ?>"
            onclick="location.href='praise_manage.php?manage=1'">
            <span class="mdi mdi-trophy-award"></span>奖励表彰
        </button>
        <button class="manage-btn<?= ($current_page == 'praise_manage.php' && $manage == 2) ? ' active' : '' ?>"
            onclick="location.href='praise_manage.php?manage=2'">
            <span class="mdi mdi-alert-circle"></span>通报批评
        </button>
        <button class="manage-btn<?= $current_page == 'time_manage.php' ? ' active' : '' ?>"
            onclick="location.href='time_manage.php'">
            <span class="mdi mdi-calendar-clock"></span>值班安排
        </button>
        <button class="manage-btn<?= $current_page == 'course_schedule_manage.php' ? ' active' : '' ?>"
            onclick="location.href='course_schedule_manage.php'">
            <span class="mdi mdi-table"></span>课表展示
        </button>
        <button class="manage-btn<?= $current_page == 'media.php' ? ' active' : '' ?>"
            onclick="location.href='media.php?manage=1'">
            <span class="mdi mdi-video"></span>媒体播放
        </button>
        <button class="manage-btn<?= $current_page == 'password_change.php' ? ' active' : '' ?>"
            onclick="location.href='manage.php'">
            <span class="mdi mdi-key"></span>修改密码
        </button>
        <button class="manage-btn" type="submit" onclick="location.href='logout.php'"><span class="mdi mdi-logout"></span>退出登录</button>
    </div>
<?php
}
?>
